package cn.edu.xmu.orderpayment.order.model.bo;

import cn.edu.xmu.orderpayment.order.model.po.OrderItemPo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author Chencheng Liao 22920192204238
 * @date 2021/12/11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderItem implements Serializable {
    private Long id;

    private Long orderId;

    private Long shopId;
    private Long productId;
    private Long onsaleId;
    private Long quantity;

    private Long price;

    private Long discountPrice;
    private Long point;
    private String name;

    private Long couponActivityId;
    private Long couponId;
    private Byte commented;

    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    /**
     * 根据po构建bo
     * @param orderItemPo
     */
    public OrderItem(OrderItemPo orderItemPo) {
        this.id=orderItemPo.getId();
        this.orderId=orderItemPo.getOrderId();
        this.shopId=orderItemPo.getShopId();
        this.productId=orderItemPo.getProductId();
        this.onsaleId=orderItemPo.getOnsaleId();
        this.quantity=orderItemPo.getQuantity();
        this.price=orderItemPo.getPrice();
        this.discountPrice=orderItemPo.getDiscountPrice();
        this.point=orderItemPo.getPoint();
        this.name=orderItemPo.getName();
        this.couponActivityId=orderItemPo.getCouponActivityId();
        this.couponId=orderItemPo.getCouponId();
        this.commented=orderItemPo.getCommented();
        this.gmtCreate=orderItemPo.getGmtCreate();
        this.gmtModified=orderItemPo.getGmtModified();
        this.creatorId=orderItemPo.getCreatorId();
        this.creatorName=orderItemPo.getCreatorName();
        this.modifierId=orderItemPo.getModifierId();
        this.modifierName=orderItemPo.getModifierName();
    }
    public void init(){
        this.price=0L;
        this.discountPrice=0L;
        this.point=0L;
        this.commented=0;
    }
}
